<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/axios.min.js"></script>
    <script type="text/javascript" src="../js/vue-router.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../css/animate.css">
</head>

<body>
    <div id="app" class="container">
        <input type="text" v-model="firstname"> +
        <input type="text" v-model="lastname"> =
        <input type="text" v-model="fullname">
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                firstname: '',
                lastname: '',
                fullname: ''
            },
            methods: {},
            // 使用watch属性可以监视data中的数据的变化，然后触发watch中对应的处理函数
            watch: {
                firstname: function(newValue, oldVaule) {
                    this.firstname = newValue;
                    this.fullname = newValue + " " + this.lastname;
                },
                lastname: function(newValue) {
                    this.lastname = newValue;
                    this.fullname = this.firstname + " " + newValue;
                }

            },
        });
    </script>
</body>

</html>